/*******************************************************************************
 * Copyright (c) 2008 meihuichina.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.langqiao.proxy.dynamicproxy2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 
 */

public class MyInvocationHandler implements InvocationHandler {

	private Object target;
	public MyInvocationHandler(){};
	public MyInvocationHandler(Object target){
		this.target = target;
	}
	/**
	 * proxy:代理对象
	 * method:执行的方法
	 * args,调用该方法传递的参数
	 */
	@Override
	public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable {
		DogUtil du = new DogUtil();
		du.method1();
		Object result = method.invoke( target, args );
		du.method2();
		return result;
	}
	
	public void setTarget(Object target) {
		this.target = target;
	}
}

